package com.twu.biblioteca;

import java.io.IOException;

/**
 * Created by archoud on 3/5/14.
 * and edited by Eliza and Michael
 */
public class LibrarySystem {
    private Menu menu;
    private Out out;
    private Catalog catalog;


    public LibrarySystem(Out out, Menu menu, Catalog catalog) {
        this.menu = menu;
        this.out = out;
        this.catalog = catalog;
    }


    public void runMenuChoice() throws IOException {

        String validOption = menu.getValidMenuOption();
        if(validOption.equals("Display Library")){
            catalog.printBooks();
        }
        else if (validOption.equals("Checkout Book")){
            int bookNumber = catalog.promptUserForBook();
            catalog.checkOut(bookNumber);
        }
    }

    public void go() throws IOException {
        out.println("Welcome to Biblioteca");
        catalog.printBooks();
        menu.displayMenu();
        runMenuChoice();
    }
}
